package com.tcredit.spider.web.redis;

import java.util.concurrent.TimeUnit;

import javax.annotation.Resource;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

@Service
public class RedisService {

	@Resource
	private RedisTemplate<String, String> redisTemplate;

	public void setKey(String key, String value) {
		ValueOperations<String, String> ops = redisTemplate.opsForValue();
		ops.set(key, value, 1, TimeUnit.MINUTES);//1分钟过期
	}

	public String getValue(String key) {
		ValueOperations<String, String> ops = this.redisTemplate.opsForValue();
		return ops.get(key);
	}

}